package com.wyz.Service.Impl;


import com.wyz.Service.SysOperatorLogService;
import com.wyz.mapper.SysOperatorLogMapper;
import com.wyz.model.OperatorLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName SysOperatorLogServiceImpl
 * @description: 日志操作实现类
 * @Version 1.0
 **/
@Service
public class SysOperatorLogServiceImpl implements SysOperatorLogService {

    /***
     * 日志
     */
    private Logger logger = LoggerFactory.getLogger(SysOperatorLogServiceImpl.class);

    /**
     * 注入Dao
     **/
    @Autowired
    private SysOperatorLogMapper sysOperatorLogMapper;

    /**
     * 添加日志操作
     *
     * @param moduleName 模块名称
     * @param userName   用户名
     * @param desc       方法描述
     */
    @Override

    public void addLog(String moduleName, String userName, String desc) {
        try {

            OperatorLog operatorLog = new OperatorLog();
            operatorLog.setModuleName (moduleName);
            operatorLog.setOperatorDesc(desc);
            operatorLog.setUserName(userName);
            sysOperatorLogMapper.addLog(operatorLog);

        } catch (Exception e) {
            logger.error("添加日志操作失败:{}", e);
        }
    }

    @Override
    public List<OperatorLog> findOperatorLogAll() {
        return sysOperatorLogMapper.findOperatorLogAll();
    }

}
